Telegram Group & Telegram Channel
Solution:

def BalancedBrackets(st):
openingBrackets="([{"
closingBrackets=")]}"
matchingBrackets={ ')':'(',
'}':'{',
']':'[' }
stack=[]
for char in st:
if char in openingBrackets:
stack.append(char)
elif char in closingBrackets:
if len(stack)==0:
return False
if stack[-1]==matchingBrackets[char]:
stack.pop()
else:
return False
return len(stack)==0
print(BalancedBrackets(input()))

Share and Support @python_codes



tg-me.com/python_codes/129
Create:
Last Update:

Solution:

def BalancedBrackets(st):
openingBrackets="([{"
closingBrackets=")]}"
matchingBrackets={ ')':'(',
'}':'{',
']':'[' }
stack=[]
for char in st:
if char in openingBrackets:
stack.append(char)
elif char in closingBrackets:
if len(stack)==0:
return False
if stack[-1]==matchingBrackets[char]:
stack.pop()
else:
return False
return len(stack)==0
print(BalancedBrackets(input()))

Share and Support @python_codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/129

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

The seemingly negative pandemic effects and resource/product shortages are encouraging and allowing organizations to innovate and change.The news of cash-rich organizations getting ready for the post-Covid growth economy is a sign of more than capital spending plans. Cash provides a cushion for risk-taking and a tool for growth.

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

Python Codes from kr


Telegram Python Codes
FROM USA